package generacionCodigo;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class ArchivoAssembler {
	
	private BufferedWriter writer;
	
	public ArchivoAssembler (String path){
		try{
			writer= new BufferedWriter(new FileWriter(path));
			addLine(".386");
			addLine(".586");
			addLine(".8087");
			addLine(".model flat, stdcall");
			addLine("option casemap :none");
			//addLine("include \\masm32\\include\\windows.inc");
			//addLine("include \\masm32\\include\\kernel32.inc");
			//addLine("include \\masm32\\include\\masm32.inc");
			addLine("include \\masm32\\include\\masm32rt.inc ");
			//addLine("include \\masm32\\include\\user32.inc");
			addLine("includelib \\masm32\\lib\\kernel32.lib");
			addLine("includelib \\masm32\\lib\\user32.lib");	
			addLine("includelib \\masm32\\lib\\masm32.lib");
		}catch (IOException e){
			e.printStackTrace();
		}
	}
	
	public void addLine (String line){
		try{
			writer.append(line+'\n');
		}catch(IOException e){
			e.printStackTrace();			
		}
	}
	
	public void append (String text){
		try{
			writer.append(text);
		}catch(IOException e){
			e.printStackTrace();			
		}
	}
	
	public void cerrarArchivo (){
		try{
			addLine("\tinvoke ExitProcess,0");
			addLine("end start");
			writer.close();
		}catch(IOException e){
			e.printStackTrace();			
		}
	}
}
